<!DOCTYPE html>
<html lang="zxx">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>FoodKa - Food Ordering, Delivery & Restuarent Template</title>

    <!-- Stylesheet -->
    <link rel="stylesheet" href="static/css/animate.min.css">
    <link rel="stylesheet" href="static/css/bootstrap.min.css">
    <link rel="stylesheet" href="static/css/magnific.min.css">
    <link rel="stylesheet" href="static/css/nice-select.min.css">
    <link rel="stylesheet" href="static/css/owl.min.css">
    <link rel="stylesheet" href="static/css/slick-slide.min.css">
    <link rel="stylesheet" href="static/css/fontawesome.min.css">
    <link rel="stylesheet" href="static/css/remixicon.css">
    <link rel="stylesheet" href="static/css/style.css">
    <link rel="stylesheet" href="static/css/responsive.css">
    <!--  js  -->
    <!-- all plugins here -->
    <script src="static/js/jquery.3.6.min.js"></script>
    <script src="static/js/jquery-ui.min.js"></script>
    <script src="static/js/bootstrap.min.js"></script>
    <script src="static/js/imageloded.min.js"></script>
    <script src="static/js/counterup.js"></script>
    <script src="static/js/waypoint.js"></script>
    <script src="static/js/magnific.min.js"></script>
    <script src="static/js/isotope.pkgd.min.js"></script>
    <script src="static/js/nice-select.min.js"></script>
    <script src="static/js/fontawesome.min.js"></script>
    <script src="static/js/owl.min.js"></script>
    <script src="static/js/slick-slider.min.js"></script>
    <script src="static/js/wow.min.js"></script>
    <script src="static/js/tweenmax.min.js"></script>
    <!-- main js  -->
    <script src="static/js/main.js"></script>
    <script type="text/javascript" src="static/js/include.js"></script>

    <!--Google Fonts-->
    <link href="static/css/css2.css" rel="stylesheet">

    <script>
        $(function () {
            load();
        });
        function load(currentPage){
            $.post("/Pizza_war_exploded/Address/findMyAllAddress",
                {currentPage : currentPage},
                function (data) {
                    $list = $("#addressList");
                    var liList = '';
                    for (var i = 0; i < data.data.list.length; i++) {
                        if (data.data.list[i].sex == '男') {
                            var li = '<div class="col-lg-6">\n' +
                                '                <div class="single-item-wrap style-2">\n' +
                                '                    <div class="media">\n' +
                                '                        <div class="wrap-details">\n' +
                                '                            <h5><a href="javascript:void(0)">' + data.data.list[i].name + '&nbsp</a><span class="sex">先生</span></h5>\n' +
                                '                            <p>收货地址：' + data.data.list[i].address_detail + '\n' +
                                '                                </p>\n' +
                                '                            <div class="wrap-footer">\n' +
                                '                                <h6 class="price">联系电话：' + data.data.list[i].telephone + '</h6>\n' +
                                '                                <button onclick=window.location.href="address-detail.html?add_id='+data.data.list[i].add_id+'" class="btn btn-secondary">修改</button>\n' +
                                '                                <button onclick="del('+data.data.list[i].add_id+')" class="btn btn-secondary">删除</button>\n' +
                                '                                <button id="'+data.data.list[i].add_id+'" onclick="setDef('+data.data.list[i].add_id+')" class="btn btn-secondary">设为默认地址</button>\n' +
                                '                            </div>\n' +
                                '                        </div>\n' +
                                '                    </div>\n' +
                                '                </div>\n' +
                                '            </div>';
                        }else if (data.data.list[i].sex == '女'){
                            var li = '<div class="col-lg-6">\n' +
                                '                <div class="single-item-wrap style-2">\n' +
                                '                    <div class="media">\n' +
                                '                        <div class="wrap-details">\n' +
                                '                            <h5><a href="javascript:void(0)">' + data.data.list[i].name + '&nbsp</a><span class="sex">女士</span></h5>\n' +
                                '                            <p>收货地址：' + data.data.list[i].address_detail + '\n' +
                                '                                </p>\n' +
                                '                            <div class="wrap-footer">\n' +
                                '                                <h6 class="price">联系电话：' + data.data.list[i].telephone + '</h6>\n' +
                                '                                <button onclick=window.location.href="address-detail.html?add_id='+data.data.list[i].add_id+'" class="btn btn-secondary">修改</button>\n' +
                                '                                <button onclick="del('+data.data.list[i].add_id+')" class="btn btn-secondary">删除</button>\n' +
                                '                                <button id="'+data.data.list[i].add_id+'" onclick="setDef('+data.data.list[i].add_id+')" class="btn btn-secondary">设为默认地址</button>\n' +
                                '                            </div>\n' +
                                '                        </div>\n' +
                                '                    </div>\n' +
                                '                </div>\n' +
                                '            </div>';
                        }
                        liList += li;
                    }

                    // 拼接分页 前5后4
                    var start = data.data.currentPage - 5;
                    var end = data.data.currentPage + 4;
                    if (start < 1){// 前面不足5个
                        start = 1;
                        end = 10;
                    }
                    if (end > data.data.totalPage){ // 后面不足4个
                        end = data.data.totalPage;
                        start = end - 9;
                    }
                    if (data.data.totalPage < 10) { // 总页数不足10个
                        start = 1;
                        end = data.data.totalPage;
                    }
                    var pageList = '<div class="col-12">\n' +
                        '                    <nav>\n' +
                        '                        <ul class="pagination">';
                    // 上一页
                    var prePage = data.data.currentPage - 1;
                    if (prePage < 1){
                        prePage = 1;
                    }
                    pageList += '<li class="page-item">\n' +
                        '                        <a class="page-link" href="javascript:load('+prePage+')">\n' +
                        '                            <i class="ri-arrow-left-s-line"></i>\n' +
                        '                        </a>\n' +
                        '                    </li>';
                    // 页码
                    for (var i = start; i <= end; i++) {
                        if (i == data.data.currentPage){
                            pageList += '<li style="cursor: pointer" onclick="load('+i+')" class="page-item active"><a class="page-link" href="javascript:">'+i+'</a></li>';
                        }else {
                            pageList += '<li style="cursor: pointer" onclick="load('+i+')" class="page-item"><a class="page-link" href="javascript:load('+i+')">'+i+'</a></li>';
                        }
                    }
                    // 下一页
                    var nextPage = data.data.currentPage + 1;
                    if (nextPage > data.data.totalPage){
                        nextPage = data.data.totalPage;
                    }
                    pageList += '<li class="page-item">\n' +
                        '                        <a class="page-link" href="javascript:load('+nextPage+')">\n' +
                        '                            <i class="ri-arrow-right-s-line"></i>\n' +
                        '                        </a>\n' +
                        '                    </li>';
                    pageList += '</ul>\n' +
                        '                    </nav>\n' +
                        '                </div>';
                    liList += pageList;
                    $list.html(liList);
                },"json");
        }
        function del(aid) {
            if (confirm("确认删除该地址？")) {
                $.post("/Pizza_war_exploded/Address/deleteAddress", {aid: aid},
                    function (data) {
                        if (data.flag) {
                            load();
                        }
                    }, "json");
            }
        }
        function setDef(aid) {
            if (confirm("是否设为默认地址？")) {
                $.post("/Pizza_war_exploded/Address/setDefaultAddress", {aid: aid},
                    function (data) {
                        if (data.flag) {
                            alert("设置成功!");
                            load();
                        }
                    }, "json");
            }
        }
    </script>
</head>
<body class='sc5'>
    <!-- preloader area start -->
    <div class="preloader" id="preloader">
        <div class="preloader-inner">
            <div id="wave1">
            </div>
            <div class="spinner">
                <div class="dot1"></div>
                <div class="dot2"></div>
            </div>
        </div>
    </div>
    <!-- preloader area end -->
    <!-- search popup area start -->
    <div class="body-overlay" id="body-overlay"></div>
    <div class="td-search-popup" id="td-search-popup">
        <form action="index.html" class="search-form">
            <div class="form-group">
                <input type="text" class="form-control" placeholder="Search.....">
            </div>
            <button type="submit" class="submit-btn"><i class="fa fa-search"></i></button>
        </form>
    </div>
    <!-- //. search Popup -->

    <!-- navbar start -->
    <div id="header"></div>
    <!-- navbar end -->

    <!-- bredcrumb Area Start-->
    <section class="breadcrumb-area">
        <div class="banner-bg-img"></div>
<!--        <div class="banner-shape-1"><img src="static/picture/shape-1.png" alt="img"></div>-->
<!--        <div class="banner-shape-2"><img src="static/picture/shape-2.png" alt="img"></div>-->
        <div class="container">
            <div class="row justify-content-center">
                <div class="col-lg-6 align-self-center">
                    <div class="banner-inner text-center">
                        <h3>Choose you items
                        </h3>
                        <h1>Choose Your address
                        </h1>
                        <nav aria-label="breadcrumb">
                            <ul class="breadcrumb">
                              <li class="breadcrumb-item"><a href="javascript:;">Home</a></li>
                              <li class="breadcrumb-item active" aria-current="page">Address List</li>
                            </ul>
                        </nav>
                    </div>
                </div>
            </div>
        </div>
    </section>
    <!-- bredcrumb Area End --> 

    <!-- populer Area Start-->/
    <section class="populer-area pd-top-50 pd-bottom-120">
        <div class="container">
            <div class="row justify-content-center">
                <button onclick=window.location.href="address-add.html" class="btn btn-secondary">新增地址</button>
            </div>

            <div id="addressList" class="row justify-content-center">
                <!--<div class="col-lg-6">
                    <div class="single-item-wrap style-2">
                        <div class="media">
&lt;!&ndash;                            <div class="thumb">&ndash;&gt;
&lt;!&ndash;                                <img src="static/picture/16.png" alt="img">&ndash;&gt;
&lt;!&ndash;                            </div>&ndash;&gt;
                            <div class="wrap-details">
                                <h5><a href="single-product.html">All Season Gulliver Pizza</a></h5>
                                <p>Pizza is a savory dish of Italian origin consisting of a usually round, flattened base of leavened.</p>
                                <div class="wrap-footer">
                                    <h6 class="price">$17.00</h6>
                                    <button type="submit" class="btn btn-secondary">ADD TO CART</button>
                                </div>                            
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-lg-6">
                    <div class="single-item-wrap style-2">
                        <div class="media">
&lt;!&ndash;                            <div class="thumb">&ndash;&gt;
&lt;!&ndash;                                <img src="static/picture/16.png" alt="img">&ndash;&gt;
&lt;!&ndash;                            </div>&ndash;&gt;
                            <div class="wrap-details">
                                <h5><a href="single-product.html">All Season Gulliver Pizza</a></h5>
                                <p>Pizza is a savory dish of Italian origin consisting of a usually round, flattened base of leavened.</p>
                                <div class="wrap-footer">
                                    <h6 class="price">$17.00</h6>
                                    <button type="submit" class="btn btn-secondary">ADD TO CART</button>
                                </div>                            
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-lg-6">
                    <div class="single-item-wrap style-2">
                        <div class="media">
&lt;!&ndash;                            <div class="thumb">&ndash;&gt;
&lt;!&ndash;                                <img src="static/picture/16.png" alt="img">&ndash;&gt;
&lt;!&ndash;                            </div>&ndash;&gt;
                            <div class="wrap-details">
                                <h5><a href="single-product.html">All Season Gulliver Pizza</a></h5>
                                <p>Pizza is a savory dish of Italian origin consisting of a usually round, flattened base of leavened.</p>
                                <div class="wrap-footer">
                                    <h6 class="price">$17.00</h6>
                                    <button type="submit" class="btn btn-secondary">ADD TO CART</button>
                                </div>                            
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-lg-6">
                    <div class="single-item-wrap style-2">
                        <div class="media">
&lt;!&ndash;                            <div class="thumb">&ndash;&gt;
&lt;!&ndash;                                <img src="static/picture/16.png" alt="img">&ndash;&gt;
&lt;!&ndash;                            </div>&ndash;&gt;
                            <div class="wrap-details">
                                <h5><a href="single-product.html">All Season Gulliver Pizza</a></h5>
                                <p>Pizza is a savory dish of Italian origin consisting of a usually round, flattened base of leavened.</p>
                                <div class="wrap-footer">
                                    <h6 class="price">$17.00</h6>
                                    <button type="submit" class="btn btn-secondary">ADD TO CART</button>
                                </div>                            
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-lg-6">
                    <div class="single-item-wrap style-2">
                        <div class="media">
&lt;!&ndash;                            <div class="thumb">&ndash;&gt;
&lt;!&ndash;                                <img src="static/picture/16.png" alt="img">&ndash;&gt;
&lt;!&ndash;                            </div>&ndash;&gt;
                            <div class="wrap-details">
                                <h5><a href="single-product.html">All Season Gulliver Pizza</a></h5>
                                <p>Pizza is a savory dish of Italian origin consisting of a usually round, flattened base of leavened.</p>
                                <div class="wrap-footer">
                                    <h6 class="price">$17.00</h6>
                                    <button type="submit" class="btn btn-secondary">ADD TO CART</button>
                                </div>                            
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-lg-6">
                    <div class="single-item-wrap style-2">
                        <div class="media">
&lt;!&ndash;                            <div class="thumb">&ndash;&gt;
&lt;!&ndash;                                <img src="static/picture/16.png" alt="img">&ndash;&gt;
&lt;!&ndash;                            </div>&ndash;&gt;
                            <div class="wrap-details">
                                <h5><a href="single-product.html">All Season Gulliver Pizza</a></h5>
                                <p>Pizza is a savory dish of Italian origin consisting of a usually round, flattened base of leavened.</p>
                                <div class="wrap-footer">
                                    <h6 class="price">$17.00</h6>
                                    <button type="submit" class="btn btn-secondary">ADD TO CART</button>
                                </div>                            
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-lg-6">
                    <div class="single-item-wrap style-2">
                        <div class="media">
&lt;!&ndash;                            <div class="thumb">&ndash;&gt;
&lt;!&ndash;                                <img src="static/picture/16.png" alt="img">&ndash;&gt;
&lt;!&ndash;                            </div>&ndash;&gt;
                            <div class="wrap-details">
                                <h5><a href="single-product.html">All Season Gulliver Pizza</a></h5>
                                <p>Pizza is a savory dish of Italian origin consisting of a usually round, flattened base of leavened.</p>
                                <div class="wrap-footer">
                                    <h6 class="price">$17.00</h6>
                                    <button type="submit" class="btn btn-secondary">ADD TO CART</button>
                                </div>                            
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-lg-6">
                    <div class="single-item-wrap style-2">
                        <div class="media">
&lt;!&ndash;                            <div class="thumb">&ndash;&gt;
&lt;!&ndash;                                <img src="static/picture/16.png" alt="img">&ndash;&gt;
&lt;!&ndash;                            </div>&ndash;&gt;
                            <div class="wrap-details">
                                <h5><a href="single-product.html">All Season Gulliver Pizza</a></h5>
                                <p>Pizza is a savory dish of Italian origin consisting of a usually round, flattened base of leavened.</p>
                                <div class="wrap-footer">
                                    <h6 class="price">$17.00</h6>
                                    <button type="submit" class="btn btn-secondary">ADD TO CART</button>
                                </div>                            
                            </div>
                        </div>
                    </div>
                </div>
                <div class="col-12">
                    <nav>
                        <ul id="pageUl" class="pagination">
                            <li class="page-item">
                            <a class="page-link" href="#">
                                <i class="ri-arrow-left-s-line"></i>
                            </a>
                            </li>
                            <li class="page-item active"><a class="page-link" href="#">1</a></li>
                            <li class="page-item"><a class="page-link" href="#">2</a></li>
                            <li class="page-item"><a class="page-link" href="#">3</a></li>
                            <li class="page-item">
                            <a class="page-link" href="#">
                                <i class="ri-arrow-right-s-line"></i>
                            </a>
                            </li>
                        </ul>
                    </nav>
                </div>-->
            </div>
        </div>
    </section>
    <!-- populer Area End -->

    <!-- footer area start -->
    <div id="footer"></div>
    <!-- footer area end -->    

    <!-- back-to-top end -->
    <div class="back-to-top">
        <span class="back-top"><i class="fas fa-angle-double-up"></i></span>
    </div>

</body>
</html>